package ${pkName}.controller;

import ${pkName}.entity.${className?cap_first};
import ${pkName}.service.${className?cap_first}Service;


import cn.wyj.common.web.BaseResponse;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/${className?uncap_first}")
@Slf4j
public class ${className}Controller   {

@Autowired
private ${className?cap_first}Service ${className?lower_case}Service;

/**
* 按条件分页查询${className?lower_case}
* @param page 第几页
* @param rows 一页多少条
* @param ${className?lower_case}
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
public BaseResponse list( @RequestParam(required = false,defaultValue = "1") int page,
@RequestParam(required = false,defaultValue = "20") int rows, ${className?cap_first} ${className?lower_case}) {
return BaseResponse.ok( ${className?lower_case}Service.findByPageCondition(page, rows, ${className?lower_case}));
}

/**
* 保存${className?lower_case}信息
* @param ${className?lower_case}
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
public BaseResponse save(${className?cap_first} ${className?lower_case}) {
${className?lower_case}Service.save(${className?lower_case});
return BaseResponse.ok( "添加成功" );
}

/**
*根据id查询回显要编辑的${className?cap_first}
* @param id
* @return
*/
@RequestMapping(value = "/get",method = RequestMethod.GET)
public BaseResponse get(String id){
return BaseResponse.ok( ${className?lower_case}Service.findById(id));
}

/**
* 修改${className?lower_case}信息
* @param ${className?lower_case}
* @return
*/
@RequestMapping(value = "/update",method = RequestMethod.POST)
public BaseResponse update(${className?cap_first} ${className?lower_case}){
${className?lower_case}Service.update(${className?lower_case});
return BaseResponse.ok( "更新成功");
}

/**
* 批量删除
*
* @param ids id 集合
* @return
*/
@RequestMapping(value = "/del", method = RequestMethod.POST)
public BaseResponse del(  String[] ids) {
${className?lower_case}Service.delByIds(ids);
return BaseResponse.ok(  "删除成功");
}


}
